package cn.lili.controller.operationcenter;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.operationcenter.entity.vos.OperationCenterSupplierVo;
import cn.lili.modules.operationcenter.entity.vos.UrbanStationSearchParams;
import cn.lili.modules.service.UrbanStationSupplierService;
import cn.lili.modules.urbansubstation.entity.dos.UrbanSubstation;
import cn.lili.modules.urbansubstation.entity.dto.UrbanSubstationSearchParams;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Api(tags = "运营中心-服务商")
@RequestMapping("/operationCenter/urbanStationSupplier")
@RequiredArgsConstructor
public class UrbanStationSupplierController {

    private final UrbanStationSupplierService urbanStationSupplierService;

    @GetMapping
    @ApiOperation("分页获取服务商列表")
    public ResultMessage<Page<UrbanSubstation>> getByPage(UrbanSubstationSearchParams searchParams, PageVO page) {
        return ResultUtil.data(urbanStationSupplierService.getUrbanByPage(searchParams, page));
    }

    @GetMapping("/supplierCount")
    @ApiOperation("服务商详情-供应商数量")
    public ResultMessage<Object> supplierCount(UrbanStationSearchParams params) {
        long supplierCount = urbanStationSupplierService.getUrbanSupplierCount(params);
        Map<String, Object> resultMap = Maps.newHashMap();
        resultMap.put("supplierCount", supplierCount);
        return ResultUtil.data(resultMap);
    }

    @GetMapping("/goodsCount")
    @ApiOperation("服务商详情-商品数量")
    public ResultMessage<Object> goodsCount(UrbanStationSearchParams params) {
        long goodsCount = urbanStationSupplierService.getUrbanGoodsCount(params);
        Map<String, Object> resultMap = Maps.newHashMap();
        resultMap.put("goodsCount", goodsCount);
        return ResultUtil.data(resultMap);
    }

    @GetMapping("/getSupplierByPage")
    @ApiOperation("服务商详情")
    public ResultMessage<Page<OperationCenterSupplierVo>> getSupplierByPage(String supplierName, String urbanId, PageVO page) {
        return ResultUtil.data(urbanStationSupplierService.getSupplierByPage(supplierName, urbanId, page));
    }
}
